package com.huqu.daoimpl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.huqu.basedao.QbDaoSupport;
import com.huqu.basedao.QbEntityMapper;
import com.huqu.basedao.QbSqlParam;
import com.huqu.dao.N100Dao;
import com.huqu.entities.N100;
import com.huqu.utils.ApplicationConstant;
import com.huqu.utils.SqlNames;

@Repository(value = ApplicationConstant.REPOSITORY_NAME_N100)
@Scope("prototype")
public class N100DaoImpl extends QbDaoSupport implements N100Dao {

	@Override
	public List<N100> ListOfTabN100(int nIDMUC, int nSTATUS, String vLANG) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.INTEGER, nSTATUS));
		listParams.add(new QbSqlParam(Types.CHAR, vLANG));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABN100);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(N100.class));
		executeQueenBQuery();
		List<N100> listN100 = (List<N100>) getListReturn();
		return listN100;
	}

	@Override
	public int InsertTabN100(int nIDTHELOAI, int nIDMUC, String vTENTHELOAI_VI,
			String vTENTHELOAI_EN, String vHINHANH, int nNGUOITAO, int nDAXOA,
			int nKIEMDUYET, int nUUTIEN) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDTHELOAI));
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.CHAR, vTENTHELOAI_VI));
		listParams.add(new QbSqlParam(Types.CHAR, vTENTHELOAI_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vHINHANH));
		listParams.add(new QbSqlParam(Types.INTEGER, nNGUOITAO));
		listParams.add(new QbSqlParam(Types.INTEGER, nDAXOA));
		listParams.add(new QbSqlParam(Types.INTEGER, nKIEMDUYET));
		listParams.add(new QbSqlParam(Types.INTEGER, nUUTIEN));
		setQueenBListSqlParams(listParams);
		// set fuction
		setQbFunction(true);
		setQbFunctionReturnType(Types.INTEGER);
		setQueenBSqlName(SqlNames.INSERTTABN100);
		executeQueenBQuery();
		int re = Integer.parseInt(getObjectReturnFunction().toString());
		return re;
	}

}
